// 渲染部分
var box=document.querySelector(".box");
let xhr1=new XMLHttpRequest();
xhr1.open("get","http://chst.vip:1234/api/getcoupon",false);
xhr1.onload=function(){
let lis1="";
if(xhr1.status===200){
let res1=JSON.parse(xhr1.responseText);
console.log(res1.result);
res1.result.forEach(x => {
                    lis1+=`
                    <div class="smbox" id="${x.couponId}">
                         <img src="${x.couponImg}" alt="">
                         <p>${x.couponTitle}</p>
                    </div>
`              
});
}
box.innerHTML=lis1;
}
xhr1.send();

// 点击获取id 跳转页面

box.onclick=function(e){
                    var e=e ||window.event;
                    var target=e.target || e.srcElment;
                    if(target.nodeName==="IMG"||target.nodeName==="P"){
                                        proId=target.parentNode.id;
                                       
                    }else if(target.nodeName==="DIV"){
                                        proId=target.id;          
                    }
                   window.location.href="../html/youhuidetail.html?couponid="+proId
}